package com.chuhe.starry.service.adapter;

import com.chuhe.common.domain.entity.UserContactApply;
import com.chuhe.common.domain.enums.PageSize;
import com.chuhe.common.domain.enums.UserContactApplyStatusEnum;
import com.chuhe.common.domain.vo.req.DealApplyReq;
import com.chuhe.common.domain.vo.resp.LoadApplyResp;
import com.chuhe.common.domain.vo.resp.UserConcactResp;

import java.util.Date;

/**
 * @Author: 楚河
 * @Date: 2025年05月16日16:57
 */
public class UserContactApplyAdapter {
    /**
     * 组装申请记录
     * @Author: 楚河
     * @Date: 2025-05-16 17:22
     */
    public static UserContactApply buildAddUserContactApply(String userId, Integer type, String receiveUserId, long curDate, String contactId, int ordinal, String applyInfo) {
        UserContactApply userContactApply = new UserContactApply();
        userContactApply.setApplyUserId(userId);
        userContactApply.setReceiveUserId(receiveUserId);
        userContactApply.setContactType(type);
        userContactApply.setContactId(contactId);
        userContactApply.setLastApplyTime(curDate);
        userContactApply.setStatus(UserContactApplyStatusEnum.INIT.getStatus());
        userContactApply.setApplyInfo(applyInfo);
        return userContactApply;
    }
    /**
     * 更新组装申请记录
     * @Author: 楚河
     * @Date: 2025-05-16 17:26
     */
    public static UserContactApply buildEditUserContactApply(Integer status, long curDate, String applyInfo) {
        UserContactApply userContactApply = new UserContactApply();
        userContactApply.setLastApplyTime(curDate);
        userContactApply.setStatus(UserContactApplyStatusEnum.INIT.getStatus());
        userContactApply.setApplyInfo(applyInfo);
        return userContactApply;
    }
    /**
     * 组装好友申请查询
     * @Author: 楚河
     * @Date: 2025-05-16 18:46
     */
    public static LoadApplyResp buildLoadApply(String userId, Integer pageNo) {
        LoadApplyResp applyResp = new LoadApplyResp();
        applyResp.setReceiveUserId(userId);
        applyResp.setPageNo(pageNo);
        applyResp.setPageSize(PageSize.SIZE15.getSize());
        applyResp.setOrderBy("last_apply_time desc");
        applyResp.setQueryContactInfo(true);
        return applyResp;
    }
    /**
     * 组装记录表更新
     * @Author: 楚河
     * @Date: 2025-05-16 20:23
     */
    public static UserContactApply buildUpdateApply(DealApplyReq req) {
        UserContactApply userContactApply = new UserContactApply();
        userContactApply.setStatus(req.getStatus());
        long curDate = System.currentTimeMillis();
        userContactApply.setLastApplyTime(curDate);
        userContactApply.setApplyId(req.getApplyId());
        return userContactApply;
    }
}
